package com.zzc.study.config;


import com.zzc.study.service.ChatAssistant;
import com.zzc.study.service.ChatAssistantDeepSeek;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther zzyy
 * @create 2025-02-21 22:42
 */
@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig
{

    @Bean(name = "qwen")
    public ChatLanguageModel chatLanguageModelByQwen()
    {
        return
                OpenAiChatModel.builder()
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .modelName("qwen-turbo-0624")
                    .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
            .build();
    }


    @Bean(name="deepseek")
    public ChatLanguageModel chatLanguageModelByDeepSeek()
    {
        return
                OpenAiChatModel.builder()
                        .apiKey(System.getenv("deepseek-api"))
                        .modelName("deepseek-chat")
                        .baseUrl("https://api.deepseek.com/v1")
                        .build();
    }



    // 你使用第2种类，高阶API    AiService
    @Bean(name = "qwenAssistant")
    public ChatAssistant chatAssistantQwen(@Qualifier("qwen") ChatLanguageModel chatLanguageModelByQwen)
    {
        return AiServices.create(ChatAssistant.class, chatLanguageModelByQwen);
    }

    @Bean(name = "deepseekAssistant")
    public ChatAssistantDeepSeek chatAssistantDeepSeek(@Qualifier("deepseek") ChatLanguageModel chatLanguageModelByDeepSeek)
    {
        return AiServices.create(ChatAssistantDeepSeek.class, chatLanguageModelByDeepSeek);
    }
}
